<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2016/8/29
  Time: 15:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>评价信息</title>
    <script src="../js/jquery/jquery-1.8.0.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../js/semanticUI/dist/semantic.min.css">
    <script src="../js/semanticUI/dist/semantic.min.js"></script>
    <script src="../js/jw/jw.js"></script>
    <script type="application/javascript">
        $(function () {
            var score = '${evaluation.evalScore }';
            var radio_score = $("input:radio[name='score']");
            switch (score) {
                case '0':
                    radio_score.eq(4).attr("checked", true);
                    break;
                case '2':
                    radio_score.eq(3).attr("checked", true);
                    break;
                case '3':
                    radio_score.eq(2).attr("checked", true);
                    break;
                case '4':
                    radio_score.eq(1).attr("checked", true);
                    break;
                case '5':
                    radio_score.eq(0).attr("checked", true);
                    break;
                default:
            }

            var viewModel = '${viewModel}';
            if (viewModel == "viewModel") {
                radio_score.attr("disabled", true);
            } else {
                radio_score.parent("span").css({"cursor": "pointer"});
                radio_score.parent("span").on("click", function () {
                    $(this).children("input:radio[name='score']").attr("checked", true);
                })
            }
        });

        function doSave() {
            var score = $('input:radio[name="score"]:checked').val();
            var evalContent = $("#evalContent").val();
            if (evalContent == null || evalContent == "") {
                evalContent = "系统默认好评";
            }
            if (score == null || score == undefined) {
                alert("请选择评分");
                return;
            } else if (confirm("确定要保存评价吗？")) {
                $.post("./save", {
                    "relationId": "${relationId}",
                    "evalId": "${evalId}",
                    "pId": "${pId}",
                    "evalContent": evalContent,
                    'evalScore':score
                }, function (data) {
                    alert(data.msg);
                    if (data.result) {
                        window.close();
                        parent.location.reload();
                    }
                }, "json");
            }
        }
    </script>
</head>
<body>
<div style="width: 100%;margin: auto;line-height: 40px;padding: 0px 10px;">
    <div style="float:left;width:33%;" align="right">
        <div style="width: 260px;">业务编号：<input type="text" disabled
                                               value="${declaaration.businessId }"></div>
        <div style="width: 260px;">实际委托人：<input type="text" disabled
                                                value="${declaaration.customer.name }"></div>
    </div>
    <div style="float:left;width:33%;" align="right">
        <div style="width: 260px;">集装箱号：<input type="text" disabled
                                               value="${declaaration.container_no }"></div>
        <div style="width: 260px;">收发货人：<input type="text" disabled
                                               value="${declaaration.company_name }"></div>
    </div>
    <div style="float:left;width:33%;" align="right">
        <div style="width: 260px;">合同协议号：<input type="text" disabled
                                                value="${declaaration.contract_no }"></div>
    </div>
    <div class="rating demos" style="padding-top: 100px;">
        <div class="ui relaxed divided items">
            <c:forEach var="er" items="${evaluationRecords}">
                <div class="item">
                    <div class="ui tiny image" style="width: 150px;">
                            ${er.evalPerson}：
                    </div>
                    <div class="content">
                        <div class="description">
                                ${er.evalContent}
                        </div>
                        <div class="extra" style="text-align: right;">
                                ${er.evalTime}
                        </div>
                    </div>
                </div>
            </c:forEach>
            <div class="item">
                <div class="content">
                    <div class="description">
                        <c:if test="${viewModel ne 'viewModel'}">
                            <textarea style="width: 100%;height: 150px;"
                                      id="evalContent" placeholder="请填写评语，若不填写系统自动默认好评"></textarea>
                        </c:if>
                    </div>
                    <div class="extra" style="text-align: right;">
                        <span><input type="radio" name="score" value="5">很满意</span>
                        <span><input type="radio" name="score" value="4">满意</span>
                        <span><input type="radio" name="score" value="3">一般</span>
                        <span><input type="radio" name="score" value="2">不满意</span>
                        <span><input type="radio" name="score" value="0">很不满意</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div align="center">
        <div class="ui buttons">
            <c:choose>
                <c:when test="${viewModel eq 'viewModel'}">
                    <div class="ui button" onclick="javascript:window.close();jw.close();">关闭</div>
                </c:when>
                <c:otherwise>
                    <div class="ui button" onclick="javascript:window.close();jw.close();">取消</div>
                    <div class="or"></div>
                    <div class="ui positive button" onclick="javascript:doSave();">保存</div>
                </c:otherwise>
            </c:choose>
        </div>
    </div>
</div>
</body>
</html>
